using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

//创建时间：2025-08-27
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 
    /// </summary>
    [Verify]
    [Route("business/CksBarcodeRelRec")]
    [ApiExplorerSettings(GroupName = "business")]
    public class CksBarcodeRelRecController : BaseController
    {
        /// <summary>
        /// 接口
        /// </summary>
        private readonly ICksBarcodeRelRecService _CksBarcodeRelRecService;

        public CksBarcodeRelRecController(ICksBarcodeRelRecService CksBarcodeRelRecService)
        {
            _CksBarcodeRelRecService = CksBarcodeRelRecService;
        }

        /// <summary>
        /// 查询列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "cksbarcoderelrec:list")]
        public IActionResult QueryCksBarcodeRelRec([FromQuery] CksBarcodeRelRecQueryDto parm)
        {
            var response = _CksBarcodeRelRecService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "cksbarcoderelrec:query")]
        public IActionResult GetCksBarcodeRelRec(int Id)
        {
            var response = _CksBarcodeRelRecService.GetInfo(Id);
            
            var info = response.Adapt<CksBarcodeRelRecDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "cksbarcoderelrec:add")]
        [Log(Title = "", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCksBarcodeRelRec([FromBody] CksBarcodeRelRecDto parm)
        {
            var modal = parm.Adapt<CksBarcodeRelationshipRecord>().ToCreate(HttpContext);

            var response = _CksBarcodeRelRecService.AddCksBarcodeRelRec(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "cksbarcoderelrec:edit")]
        [Log(Title = "", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCksBarcodeRelRec([FromBody] CksBarcodeRelRecDto parm)
        {
            var modal = parm.Adapt<CksBarcodeRelationshipRecord>().ToUpdate(HttpContext);
            var response = _CksBarcodeRelRecService.UpdateCksBarcodeRelRec(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "cksbarcoderelrec:delete")]
        [Log(Title = "", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCksBarcodeRelRec([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_CksBarcodeRelRecService.Delete(idArr));
        }

    }
}